package com.source.auto.model;

import cn.hutool.core.util.StrUtil;
import lombok.Data;

/**
 * @author wangchangjie
 * @date 2025/1/16 11:37
 */
@Data
public class ExcelTemplateInfo {

    /**
     * 服务名称
     */
    private String serviceName;
    /**
     * 基本服务
     */
    private String baseService;
    /**
     * 适用环境 "仅公有" 、"仅私有" 、 "公私兼备"
     */
    private String applicableEnvironment;
    /**
     * 私有化定制
     */
    private String privatizationCustomization;
    /**
     * 新服务
     */
    private String newService;
    /**
     * main 分支
     */
    private String mainBranch;
    /**
     * 测试 merge 分支
     */
    private String testMergeBranch;
    /**
     * 当前开发分支
     */
    private String currDevBranch;
    /**
     * 架构类型
     */
    private String architectureType;
    /**
     * 所有者
     */
    private String owner;
    /**
     * 备注
     */
    private String remark;


    public String getWebExcelInfo(String template) {
        return template.replace("#{serviceName}", this.serviceName)
            .replace("#{baseService}", this.baseService)
            .replace("#{applicableEnvironment}", this.applicableEnvironment)
            .replace("#{privatizationCustomization}", this.privatizationCustomization)
            .replace("#{newService}", this.newService)
            .replace("#{mainBranch}", this.mainBranch)
            .replace("#{testMergeBranch}", this.testMergeBranch)
            .replace("#{currDevBranch}", this.currDevBranch)
            .replace("#{architectureType}", this.architectureType)
            .replace("#{owner}", StrUtil.isEmpty(this.owner) ? "" : this.owner);
    }

    public String getServiceExcelInfo(String template) {
        return template.replace("#{serviceName}", this.serviceName)
            .replace("#{baseService}", this.baseService)
            .replace("#{applicableEnvironment}", this.applicableEnvironment)
            .replace("#{privatizationCustomization}", this.privatizationCustomization)
            .replace("#{newService}", this.newService)
            .replace("#{mainBranch}", this.mainBranch)
            .replace("#{testMergeBranch}", this.testMergeBranch)
            .replace("#{currDevBranch}", this.currDevBranch)
            .replace("#{architectureType}", this.architectureType)
            .replace("#{owner}", StrUtil.isEmpty(this.owner) ? "" : this.owner);
    }

    public String getApiExcelInfo(String template) {
        return template.replace("#{serviceName}", this.serviceName)
            .replace("#{baseService}", this.baseService)
            .replace("#{applicableEnvironment}", this.applicableEnvironment)
            .replace("#{privatizationCustomization}", this.privatizationCustomization)
            .replace("#{mainBranch}", this.mainBranch)
            .replace("#{testMergeBranch}", this.testMergeBranch)
            .replace("#{currDevBranch}", this.currDevBranch)
            .replace("#{owner}", StrUtil.isEmpty(this.owner) ? "" : this.owner)
            .replace("#{remark}", StrUtil.isEmpty(this.remark) ? "" : this.remark);
    }
}
